<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>通知管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(function(){
			$(".a-model").click(function(){
				thiz = this;
				$("#detail_notify_modal").on('show', function () {
					$(".modal-body").load(thiz.href);
				});
				$("#detail_notify_modal").modal('show');
				return false;
			});
			$("#detail_notify_modal").on('hide', function () {
				$(".modal-body").empty();
			});
		});
		function page(n,s){
			loading('正在查询，请稍等...');
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

		//发布通知
		function publish(ahref,status){
			if(status == "0") {
				return confirmx('该通知已经发布，确定重新发布吗？',function(){
					initPublish(ahref);
				});
			} else {
				initPublish(ahref);
				return false;
			}
		}

		//初始发布通知化模态框
		function initPublish(ahref){
			$("#send_notify_modal").modal({
				backdrop: 'static',
				keyboard:false
			});
			$("#send_notify_modal").modal('show');
			$(".btn-primary").click(function () {
				if ($("#officesId").val()){
					$("#send_notify_modal").modal('hide');
					loading('正在发布，请稍等...');
					window.location.href = ahref.href + "&officeIds="+$("#officesId").val();
				} else {
					$("#tipLbl").show();
					return false;
				}
			});
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/office/notify/officeNotify/">通知列表</a></li>
		<shiro:hasPermission name="office:officeNotify:edit"><li><a href="${ctx}/office/notify/officeNotify/form">通知添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="officeNotify" action="${ctx}/office/notify/officeNotify/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>类型：</label>
				<form:select path="type" cssClass="select-medium">
					<form:option value="">全部</form:option>
					<c:forEach items="${fns:getDictList('OFFICE_NOTIFY_TYPE')}" var="ont">
						<form:option value="${ont.value }">${ont}</form:option>
					</c:forEach>
				</form:select>
			</li>
			<li><label>标题：</label>
				<form:input path="title" htmlEscape="false" maxlength="200" class="input-medium"/>
			</li>
			<li><label>状态：</label>
				<form:select path="status" cssClass="select-medium">
					<form:option value="">全部</form:option>
					<c:forEach items="${fns:getDictList('OFFICE_NOTIFY_STATUS')}" var="ons">
						<form:option value="${ons.value }">${ons}</form:option>
					</c:forEach>
				</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" onclick="page(1);" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed table-hover">
		<thead>	
			<tr>
				<th>序号</th>
				<th>类型</th>
				<th>标题</th>
				<th>状态</th>
				<th>备注信息</th>
				<th>创建时间</th>
				<shiro:hasPermission name="office:officeNotify:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="officeNotify" varStatus="vs">
			<tr class="list">
			
				<td>
					${vs.index + 1}
				</td>
				<td>
					${fns:getDictLabel(officeNotify.type, "OFFICE_NOTIFY_TYPE", "未知")}
				</td>
				<td>
					<a href="${ctx}/office/notify/officeNotify/view?id=${officeNotify.id}" class="a-model">
					${fns:abbr(officeNotify.title,20)}
					</a>
				</td>
				<td>
					${fns:getDictLabel(officeNotify.status, "OFFICE_NOTIFY_STATUS", "未知")}
				</td>
				<td>
					${fns:abbr(officeNotify.remarks,20)}
				</td>
				<td>
					<fmt:formatDate value="${officeNotify.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<shiro:hasPermission name="office:officeNotify:edit">
				<td>
    				<a href="${ctx}/office/notify/officeNotify/send?id=${officeNotify.id}&status=${officeNotify.status}" onclick="return publish(this,${officeNotify.status});">发布</a>
    				<c:if test="${officeNotify.status eq '1'}">
    					<a href="${ctx}/office/notify/officeNotify/form?id=${officeNotify.id}">修改</a>
    				</c:if>
    				<c:if test="${officeNotify.status eq '0'}">
    					<a href="${ctx}/office/notify/officeNotify/view?id=${officeNotify.id}" class="a-model">查看</a>
    				</c:if>
				</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<div id="detail_notify_modal" class="modal hide fade"  tabindex="-1" role="dialog" aria-labelledby="detailNotifyModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h5 id="detailNotifyModalLabel">通知详情</h5>
		</div>
		<div class="modal-body">
		</div>
		<div class="modal-footer">
    		<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">确定</button>
  		</div>
	</div>
	<div id="send_notify_modal" class="modal hide fade" style="width: auto;" tabindex="-1" role="dialog" aria-labelledby="sendNotifyModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h5 id="sendNotifyModalLabel">发布范围</h5>
		</div>
		<div class="modal-body">
			<p class="text-center">
				<sys:treeselect id="offices" name="officeIds" value="${user.office.id}" labelName="office.name"
					labelValue="${user.office.name}" title="部门" url="/sys/office/treeData?type=2"
					checked="true" allowClear="true" notAllowSelectParent="false" smallBtn="true"
					checkParentOrChild="s"/>
				<br>
				<label id="tipLbl" class="error hide">请选择发布范围</label>
			</p>
		</div>
		<div class="modal-footer">
    		<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">确定</button>
  		</div>
	</div>
</body>
</html>